<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: critical_section</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.1.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__critical__section.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">critical_section<div class="ingroups"><a class="el" href="group__high__level.html">High Level APIs</a> &raquo; <a class="el" href="group__pico__sync.html">pico_sync</a></div></div></div>
</div><!--header-->
<div class="contents">

<p>Critical Section API for short-lived mutual exclusion safe for IRQ and multi-core.  
<a href="#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga22cd2722a96179036820e87b29209cfd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__critical__section.html#ga22cd2722a96179036820e87b29209cfd">critical_section_init</a> (critical_section_t *crit_sec)</td></tr>
<tr class="memdesc:ga22cd2722a96179036820e87b29209cfd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise a <a class="el" href="structcritical__section.html">critical_section</a> structure allowing the system to assign a spin lock number.  <a href="group__critical__section.html#ga22cd2722a96179036820e87b29209cfd">More...</a><br /></td></tr>
<tr class="separator:ga22cd2722a96179036820e87b29209cfd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae1b4eb5dcab9ac679970ac43d618de2c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__critical__section.html#gae1b4eb5dcab9ac679970ac43d618de2c">critical_section_init_with_lock_num</a> (critical_section_t *crit_sec, uint lock_num)</td></tr>
<tr class="memdesc:gae1b4eb5dcab9ac679970ac43d618de2c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialise a <a class="el" href="structcritical__section.html">critical_section</a> structure assigning a specific spin lock number.  <a href="group__critical__section.html#gae1b4eb5dcab9ac679970ac43d618de2c">More...</a><br /></td></tr>
<tr class="separator:gae1b4eb5dcab9ac679970ac43d618de2c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga15e4552b4e1419faad51eba026a39aad"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__critical__section.html#ga15e4552b4e1419faad51eba026a39aad">critical_section_enter_blocking</a> (critical_section_t *crit_sec)</td></tr>
<tr class="memdesc:ga15e4552b4e1419faad51eba026a39aad"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enter a <a class="el" href="structcritical__section.html">critical_section</a>.  <a href="group__critical__section.html#ga15e4552b4e1419faad51eba026a39aad">More...</a><br /></td></tr>
<tr class="separator:ga15e4552b4e1419faad51eba026a39aad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab57fcee3973b26dced4601e6018a227c"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__critical__section.html#gab57fcee3973b26dced4601e6018a227c">critical_section_exit</a> (critical_section_t *crit_sec)</td></tr>
<tr class="memdesc:gab57fcee3973b26dced4601e6018a227c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release a <a class="el" href="structcritical__section.html">critical_section</a>.  <a href="group__critical__section.html#gab57fcee3973b26dced4601e6018a227c">More...</a><br /></td></tr>
<tr class="separator:gab57fcee3973b26dced4601e6018a227c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga08444ba7879fae8813dd5573a13f0351"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__critical__section.html#ga08444ba7879fae8813dd5573a13f0351">critical_section_deinit</a> (critical_section_t *crit_sec)</td></tr>
<tr class="memdesc:ga08444ba7879fae8813dd5573a13f0351"><td class="mdescLeft">&#160;</td><td class="mdescRight">De-Initialise a <a class="el" href="structcritical__section.html">critical_section</a> created by the critical_section_init method.  <a href="group__critical__section.html#ga08444ba7879fae8813dd5573a13f0351">More...</a><br /></td></tr>
<tr class="separator:ga08444ba7879fae8813dd5573a13f0351"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<p >Critical Section API for short-lived mutual exclusion safe for IRQ and multi-core. </p>
<p >A critical section is non-reentrant, and provides mutual exclusion using a spin-lock to prevent access from the other core, and from (higher priority) interrupts on the same core. It does the former using a spin lock and the latter by disabling interrupts on the calling core.</p>
<p >Because interrupts are disabled when a <a class="el" href="structcritical__section.html">critical_section</a> is owned, uses of the <a class="el" href="structcritical__section.html">critical_section</a> should be as short as possible. </p>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga08444ba7879fae8813dd5573a13f0351" name="ga08444ba7879fae8813dd5573a13f0351"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga08444ba7879fae8813dd5573a13f0351">&#9670;&nbsp;</a></span>critical_section_deinit()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void critical_section_deinit </td>
          <td>(</td>
          <td class="paramtype">critical_section_t *&#160;</td>
          <td class="paramname"><em>crit_sec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>De-Initialise a <a class="el" href="structcritical__section.html">critical_section</a> created by the critical_section_init method. </p>
<p >This method is only used to free the associated spin lock allocated via the critical_section_init method (it should not be used to de-initialize a spin lock created via critical_section_init_with_lock_num). After this call, the critical section is invalid</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">crit_sec</td><td>Pointer to <a class="el" href="structcritical__section.html">critical_section</a> structure </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga15e4552b4e1419faad51eba026a39aad" name="ga15e4552b4e1419faad51eba026a39aad"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga15e4552b4e1419faad51eba026a39aad">&#9670;&nbsp;</a></span>critical_section_enter_blocking()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void critical_section_enter_blocking </td>
          <td>(</td>
          <td class="paramtype">critical_section_t *&#160;</td>
          <td class="paramname"><em>crit_sec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Enter a <a class="el" href="structcritical__section.html">critical_section</a>. </p>
<p >If the spin lock associated with this critical section is in use, then this method will block until it is released.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">crit_sec</td><td>Pointer to <a class="el" href="structcritical__section.html">critical_section</a> structure </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gab57fcee3973b26dced4601e6018a227c" name="gab57fcee3973b26dced4601e6018a227c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab57fcee3973b26dced4601e6018a227c">&#9670;&nbsp;</a></span>critical_section_exit()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void critical_section_exit </td>
          <td>(</td>
          <td class="paramtype">critical_section_t *&#160;</td>
          <td class="paramname"><em>crit_sec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Release a <a class="el" href="structcritical__section.html">critical_section</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">crit_sec</td><td>Pointer to <a class="el" href="structcritical__section.html">critical_section</a> structure </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga22cd2722a96179036820e87b29209cfd" name="ga22cd2722a96179036820e87b29209cfd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga22cd2722a96179036820e87b29209cfd">&#9670;&nbsp;</a></span>critical_section_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void critical_section_init </td>
          <td>(</td>
          <td class="paramtype">critical_section_t *&#160;</td>
          <td class="paramname"><em>crit_sec</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise a <a class="el" href="structcritical__section.html">critical_section</a> structure allowing the system to assign a spin lock number. </p>
<p >The critical section is initialized ready for use, and will use a (possibly shared) spin lock number assigned by the system. Note that in general it is unlikely that you would be nesting critical sections, however if you do so you <em>must</em> use <a class="el" href="group__critical__section.html#gae1b4eb5dcab9ac679970ac43d618de2c">critical_section_init_with_lock_num</a> to ensure that the spin locks used are different.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">crit_sec</td><td>Pointer to <a class="el" href="structcritical__section.html">critical_section</a> structure </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="gae1b4eb5dcab9ac679970ac43d618de2c" name="gae1b4eb5dcab9ac679970ac43d618de2c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae1b4eb5dcab9ac679970ac43d618de2c">&#9670;&nbsp;</a></span>critical_section_init_with_lock_num()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void critical_section_init_with_lock_num </td>
          <td>(</td>
          <td class="paramtype">critical_section_t *&#160;</td>
          <td class="paramname"><em>crit_sec</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint&#160;</td>
          <td class="paramname"><em>lock_num</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialise a <a class="el" href="structcritical__section.html">critical_section</a> structure assigning a specific spin lock number. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">crit_sec</td><td>Pointer to <a class="el" href="structcritical__section.html">critical_section</a> structure </td></tr>
    <tr><td class="paramname">lock_num</td><td>the specific spin lock number to use </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>